package wrs.hcs.tc;

import org.openqa.selenium.WebDriver;

import wrs.hcs.functions.*;

public class WebAdmin_DuplicateRooms {

	public static WebDriver driver;
	public static String lName1, lName2;
	public static String pin1, pin2;
	
	public void inpatient() throws Exception
	{
		AdminConsole ac = new AdminConsole();
		Webdriver d = new Webdriver();
		Login log = new Login();
		Logout out = new Logout();
		WebApp_Single s = new WebApp_Single();
		Miscellaneous m = new Miscellaneous();
		Hcs_NewPatient newPatient = new Hcs_NewPatient();
		driver = d.startUp();
		
		//Criteria for login in hcs: "admission", "nursing", "billing"
		log.hcs(driver, "admission"); 												//login
		String getIt = newPatient.createPatient(driver, "adult");					//new patient in hcs
		out.hcs(driver); 															//logout after getting pin and lastname
		
		//Split string for PIN and LASTNAME
		String[] arrString = getIt.split(",");
		lName1 = arrString[0];
		pin1 = arrString[1];
		
		log.hcs(driver, "admission"); 												//login
		String patient2 = newPatient.createPatient(driver, "adult");				//new patient in hcs
		out.hcs(driver); 															//logout after getting pin and lastname
		
		//Split string for PIN and LASTNAME - Patient2
		String[] arrsString = patient2.split(",");
		lName2 = arrsString[0];
		pin2 = arrsString[1];
		
		s.wellness(driver, lName1, pin1, false, "basic"); 									//create wrs transaction in webapp for patient
		driver = d.startUp();
		s.wellness(driver, lName2, pin2, false, "basic");
		driver = d.startUp();
		log.admin(driver); //login
		
		ac.wellness_search_it(driver, pin1, "", "");
		ac.get_status_and_click(driver, pin1, true);
		ac.update_online_single_in_admin(driver, "inpatient");
		
		ac.wellness_search_it(driver, pin2, "", "");
		ac.get_status_and_click(driver, pin2, true);
		ac.update_online_single_in_admin(driver, "inpatient");
		
		ac.wellness_search_it(driver, pin1, "", "");
		ac.get_status_and_click(driver, pin1, false);
		String text = m.set_dropdown_to_hcs("online");
		ac.select_dropdown_to_hcs(driver, text, "single");
		ac.display_message_to_hcs(driver);
		ac.wellness_search_it(driver, pin1, "", "");
		ac.get_status_and_click(driver, pin1, false);
		
		ac.wellness_search_it(driver, pin2, "", "");
		ac.get_status_and_click(driver, pin2, false);
		text = m.set_dropdown_to_hcs("online");
		ac.select_dropdown_to_hcs(driver, text, "single");
		ac.display_message_to_hcs(driver);
		ac.wellness_search_it(driver, pin2, "", "");
		ac.get_status_and_click(driver, pin2, false);
	}
}
